﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using NEmu;

namespace Super64.Core.CPU.MIPS
{
    public sealed class MipsInstruction
    {
        private uint m_RawInstruction;
        private InstructionType m_Type;

        public MipsInstruction(uint opcodeData)
        {
            m_RawInstruction = opcodeData;
        }

        public uint RawInstruction
        {
            get { return m_RawInstruction; }
        }

        public byte Opcode
        {
            get { return (byte)((m_RawInstruction & 0xFC000000) >> 26); }
        }

        public uint JumpTarget
        {
            get { return (uint)(m_RawInstruction & 0x3FFFFFF); }
        }

        public ushort Immediate
        {
            get {return (ushort)(m_RawInstruction & 0xFFFF);}
        }

        public byte RT
        {
            get { return (byte)((m_RawInstruction & 0x1F0000) >> 16); }
        }

        public byte RS
        {
            get { return (byte)((m_RawInstruction & 0x3E00000) >> 21); }
        }

        public byte Funct
        {
            get { return (byte)(m_RawInstruction & 0x3F); }
        }

        public byte SA
        {
            get { return (byte)((m_RawInstruction & 0x3F) >> 6); }
        }

        public byte RD
        {
            get { return (byte)((m_RawInstruction & 0xF800) >> 11); }
        }
    }
}
